﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Tanmia.Basis.Data
{
    [Serializable]
    public class ConstraintViolationException : Exception
    {
        public ConstraintViolationException() { }

        public ConstraintViolationException(string message) : base(message) { }

        public ConstraintViolationException(string message, Exception inner) : base(message, inner) { }

        public ConstraintViolationException(string message, Exception innerException, string constraintName)
            : base(message, innerException)
        {
            this.ConstraintName = constraintName;
        }

        public ConstraintViolationException(string message, Exception innerException, string constraintName, Type entity, string propertyName)
            : this(message, innerException, constraintName)
        {
            this.Entity = entity;
            this.PropertyName = propertyName;
        }

        protected ConstraintViolationException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) : base(info, context) { }

        /// <summary>
        /// Gets the entity which had constraint violation.
        /// </summary>
        public Type Entity { get; protected set; }

        /// <summary>
        /// Gets the constrainted property name.
        /// </summary>
        public string PropertyName { get; protected set; }

        /// <summary>
        /// Gets the Database violated constraint name.
        /// </summary>
        public string ConstraintName { get; protected set; }
    }
}
